from selenium import webdriver
from selenium.webdriver.common.by import By
import time

# 打开游览器
driver = webdriver.Chrome()
# 打开网页
driver.get('https://www.so.com')
# 搜索输入关键字
kw = driver.find_element(By.ID,'input')
kw.send_keys('python关键字')
# 点击搜索
sr = driver.find_element(By.ID,'search-button')
sr.click()
# 获取标题打印
time.sleep(2)
print(driver.title)
# 判断关键字
if 'python' in driver.title:
    print('ok')
else:
    print('no')
# 关闭游览器
time.sleep(2)
driver.quit()